package com.bjsxt.users.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.bjsxt.users.dao.IAAdminsDao;
import com.bjsxt.users.pojo.AAdmins;
import com.bjsxt.users.service.IAdminsService;

@Service("adminsService")
public class AdminsServiceImple implements IAdminsService {

	@Resource
	private IAAdminsDao adminsDao;
	
	/**
	 * 查询一条记录
	 */
	@Override
	public AAdmins findOneAdminsService(Map<String, Object> condMap) {

		return this.adminsDao.findOne(condMap);
	}

	/**
	 * 插入一条记录
	 */
	@Override
	public JSONObject insert(AAdmins admins) {
		
		JSONObject resultJSON = new JSONObject();
		int res = adminsDao.insert(admins);
		
		/*String str = null; 
		str.toString();*/ 
		
		if(res > 0){
			resultJSON.put("code", 1);
			resultJSON.put("info", "插入成功");
		}else{
			resultJSON.put("code", 0);
			resultJSON.put("info", "插入失败");
		}
		return resultJSON;
	}

	/**
	 * 更新一条记录
	 */
	@Override
	public JSONObject update(AAdmins admins) {
		
		JSONObject resultJSON = new JSONObject();
		int res = adminsDao.update(admins);
		
		if(res > 0){
			resultJSON.put("code", 1);
			resultJSON.put("info", "更新成功");
		}else{
			resultJSON.put("code", 0);
			resultJSON.put("info", "更新失败");
		}
		return resultJSON;
	}

	/**
	 * 删除一条记录
	 */
	@Override
	public JSONObject delete(AAdmins admins) {
		
		JSONObject resultJSON = new JSONObject();
		int res = adminsDao.delete(admins);
		
		if(res > 0){
			resultJSON.put("code", 1);
			resultJSON.put("info", "删除成功");
		}else{
			resultJSON.put("code", 0);
			resultJSON.put("info", "删除失败");
		}
		return resultJSON;
	}

	@Override
	public List<AAdmins> findCondListAdminsService(Map<String, Object> condMap) {

		return null;
	}	
}
